package cn.wolfcode.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public abstract class RandomUtil {

    //单选的随机
    public static int[] oneArray(Integer count){
        //单选的id
        int[] arrOne = new int[]{1,2,4,5,6};
        //用来存储已经生成的索引
        List<Integer> destIndexOne = new ArrayList<>();
        //根据count随机生成count个索引
        Random random = new Random();
        while (destIndexOne.size() < count){
            int i = random.nextInt(4);
            if(!(destIndexOne.contains(i))){
                destIndexOne.add(i);
            }
        }
        //根据索引找到数组的元素并返回一个数组
        int[] destOne = new int[count];
        for (int i = 0; i < destIndexOne.size(); i++) {
            int temp = destIndexOne.get(i);
            destOne[i] = arrOne[temp];
        }
        return destOne;
    }

    //多选的随机
    public static int[] manyArray(Integer count){
        //单选的id
        int[] arrMany = new int[]{3,7,8,9};
        //用来存储已经生成的索引
        List<Integer> destIndexMany = new ArrayList<>();

        //根据count随机生成count个索引
        Random random = new Random();
        while (destIndexMany.size() < count){
            int i = random.nextInt(3);
            if(!(destIndexMany.contains(i))){
                destIndexMany.add(i);
            }
        }
        //根据索引找到数组的元素并返回一个数组
        int[] destMany = new int[count];
        for (int i = 0; i < destIndexMany.size(); i++) {
            int temp = destIndexMany.get(i);
            destMany[i] = arrMany[temp];
        }
        return destMany;
    }

    //判断的随机
    public static int[] judgeArray(Integer count){
        //单选的id
        int[] arrJudge = new int[]{10,11,12,13,14,15,16,17};

        //用来存储已经生成的索引
        List<Integer> destIndexJudge = new ArrayList<>();

        //根据count随机生成count个索引
        Random random = new Random();
        while (destIndexJudge.size() < count){
            int i = random.nextInt(7);
            if(!(destIndexJudge.contains(i))){
                destIndexJudge.add(i);
            }
        }
        //根据索引找到数组的元素并返回一个数组
        int[] destJudge = new int[count];
        for (int i = 0; i < destIndexJudge.size(); i++) {
            int temp = destIndexJudge.get(i);
            destJudge[i] = arrJudge[temp];
        }
        return destJudge;
    }
}
